﻿<section class="vender">
    <div class="venderHead">
        <a class="venderHeadFl fll"><img src="/images/point_icon.png"><span id="venderName"></span></a>
        <a class="venderHeadFr flr" id="selectVender" onclick="selectVender()" style="display:none"><span>切换货机</span></a>
    </div>
</section>
<section id="mainWindows" class="IndexCon"></section>
<section id="shopping" class="Shopping"></section>
<section class="OrderGray" onclick="hideShoppingCar()"></section>

<script>
    $(function () {
        var menuList = TerminalMgr.getTerminalTabList();
        var venderInfo = TerminalMgr.getTerminalInfo();
        var nearVenderCount = TerminalMgr.getNearVenderCount();
        adjustMenuView(menuList);
        adjustVenderInfo(venderInfo, nearVenderCount);
    });

    function adjustMenuView(menuList) {
        loadShopping();
        loadConvenient(menuList);
    }

    function loadShopping() {
        var shoppingList = ShoppingMgr.getShoppingList();
        var url = '/Home/Shopping';
        NativeAjax(shoppingList, url, function (msg) {
            loadPartialViewResult(msg, $("#shopping"), 1);
        });
    }

    function loadConvenient(menuList) {
        var url = '/Home/ShowMenuList';
        NativeAjax(menuList, url, function (msg) {
            loadPartialViewResult(msg, $("#mainWindows"), 1);
        });
    }

    function adjustVenderInfo(venderInfo, venderCount) {
        if (venderInfo != null) {
            $("#venderName").text(venderInfo.name);

            if (venderCount > 1) {
                $("#selectVender").show();
            } else {
                $("#selectVender").hide();
            }
        }
    }

    function selectVender() {
        window.location.href = '/SearchVender/Index';
    }

</script>